package org.jeecg.modules.reportLabel.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.reportLabel.entity.ReportLabel;

import java.util.List;

/**
 * @Description: 标签统计报表
 * @Author: jeecg-boot
 * @Date: 2023-12-01
 * @Version: V1.0
 */
public interface ReportLabelMapper extends BaseMapper<ReportLabel> {

    ReportLabel getOneForUpdate(String originalLabelNumber);

    List<String> listBySkuCode(@Param(Constants.WRAPPER) LambdaQueryWrapper<ReportLabel> reportLabelLambdaQueryWrapper);

    @Select("SELECT * FROM report_label ${ew.customSqlSegment}")
    IPage<ReportLabel> inventoryPage(@Param("page") Page<ReportLabel> page, @Param("ew") QueryWrapper<ReportLabel> queryWrapper);

    @Select("SELECT * FROM report_label ${ew.customSqlSegment}")
    List<ReportLabel> inventoryList(@Param("ew") QueryWrapper<ReportLabel> queryWrapper);

    // compartment_code AS id是因为前端渲染不传id会报错
    @Select("SELECT compartment_code AS id,sku_code,compartment_code,SUM(available_box_inventory) AS number FROM report_label ${ew.customSqlSegment}")
    List<ReportLabel> getBasicShelfReportLabel(@Param("ew") QueryWrapper<ReportLabel> queryWrapper);

}
